API: widget: Add gtk_widget_queue_allocate()
authorBenjamin Otte <otte@redhat.com>
Mon, 14 Sep 2015 15:56:05 +0000 (17:56 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 28 Oct 2015 18:44:27 +0000 (19:44 +0100)
This is so widgets can queue a rerun of their allocation logic, but
without triggering resizes everywhere.

For now, it just calls gtk_widget_queue_resize().

gtk/gtkwidget.c
gtk/gtkwidget.h

index cb2a178364790a6425804aeaef04dfe5ab08b03b..75fa7434f7af16adf28f1eb5f67f9f19d90ca395 100644 (file)
@@ -5576,6 +5576,28 @@ gtk_widget_queue_draw (GtkWidget *widget)
                                 0, 0, rect.width, rect.height);
 }
 
+/**
+ * gtk_widget_queue_allocate:
+ * @widget: a #GtkWidget
+ *
+ * This function is only for use in widget implementations.
+ *
+ * Flags the widget for a rerun of the GtkWidgetClass::size_allocate
+ * function. Use this function instead of gtk_widget_queue_resize()
+ * when the @widget's size request didn't change but it wants to
+ * reposition its contents.
+ *
+ * An example user of this function is gtk_widget_set_halign().
+ */
+void
+gtk_widget_queue_allocate (GtkWidget *widget)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  /* for now... */
+  gtk_widget_queue_resize (widget);
+}
+
 /**
  * gtk_widget_queue_resize:
  * @widget: a #GtkWidget
@@ -10979,7 +11001,7 @@ gtk_widget_error_bell (GtkWidget *widget)
 
   settings = gtk_widget_get_settings (widget);
   if (!settings)
-    return;
+  return;
 
   g_object_get (settings,
                 "gtk-error-bell", &beep,
@@ -14544,7 +14566,7 @@ gtk_widget_set_halign (GtkWidget *widget,
     return;
 
   widget->priv->halign = align;
-  gtk_widget_queue_resize (widget);
+  gtk_widget_queue_allocate (widget);
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_HALIGN]);
 }
 
@@ -14610,7 +14632,7 @@ gtk_widget_set_valign (GtkWidget *widget,
     return;
 
   widget->priv->valign = align;
-  gtk_widget_queue_resize (widget);
+  gtk_widget_queue_allocate (widget);
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_VALIGN]);
 }
 
index e98c537b347dc1f296168ba5ca32cf5b83df7f60..61881c2ed6d750defc0f2f365a4ead49a3845a1c 100644 (file)
@@ -663,6 +663,8 @@ GDK_AVAILABLE_IN_ALL
 void      gtk_widget_queue_resize        (GtkWidget           *widget);
 GDK_AVAILABLE_IN_ALL
 void      gtk_widget_queue_resize_no_redraw (GtkWidget *widget);
+GDK_AVAILABLE_IN_3_20
+void       gtk_widget_queue_allocate      (GtkWidget           *widget);
 GDK_AVAILABLE_IN_3_8
 GdkFrameClock* gtk_widget_get_frame_clock (GtkWidget           *widget);